<script setup>
import BaseChart from '@/components/leftChart.vue';
import targetBox from '@/components/targetBox.vue';
import decorationBox from '@/components/decorationBox.vue';
import selectBox from '@/components/selectBox.vue';
import rightChart from '@/components/rightChart.vue';
import spellingBox from '@/components/spellingBox.vue';
import axios from 'axios';
import { ref, onMounted, onUnmounted, computed, nextTick, watch } from 'vue';
import { useDebounceFn } from '@vueuse/core';
import { ElMessage, ElMessageBox } from 'element-plus';
import { useCounterStore } from '@/stores/counter';
import { ElNotification } from 'element-plus';
import dayjs from 'dayjs';
const counterStore = useCounterStore();

const isChoosed = ref(false)

//坚持的天数
const targetDay = ref(0)

//上次完成的单词数
const lastFinishWords = ref(0)

// 正确率
const correctPercent = ref(0)
// 定制目标逻辑
const customTarget = () => {
  ElMessageBox.prompt('请输入目标进度（0-200）', '定制目标', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
  }).then(({ value }) => {
    const reg = value.match(/^\d+$/) ? Number(value) : null;
    if (reg === null) {
      ElMessage({
        type: 'error',
        message: '请输入正确的目标进度',
      })
      return;
    }

    if (reg < 0 || reg > 200) {
      ElMessage({
        type: 'error',
        message: '目标进度必须在0-200之间',
      })
      return;
    }
    counterStore.dailyScheduleProps = value;
    ElMessage({
      type: 'success',
      message: `您的目标进度已修改为:${value}`,
    })
  })
    .catch(() => {
      ElMessage({
        type: '提示',
        message: '输入取消',
      })
    })
}

// 开始/继续/暂停/结束标识
const isStart = ref(false)
const isContinue = ref(false)
const isPause = ref(false)
const isEnd = ref(false)
const isAllDone = ref(false)

//错误次数
const wrongNum = ref(0)
const isCorrect = ref(false)

//作答次数
const respondCount = ref(0)
// 拼写单词的长度
const spellingLength = ref(5)

// 拼写单词的输入框
const spellingBoxRef = ref(null)
// 拼写单词的答案
const spellingAnswer = ref('')

const spellingValue = ref('')

const wordTest_word = ref('')
const correctionChoosed = ref('')
const wordTest_spelling = ref('')
//耗时
const consumingTime_centisecond = ref('00')
const consumingTime_second = ref('00')
const consumingTime_minute = ref('00')
//最终耗时
const endTime = ref(0)

// 模式随机选择:0表示选择释义模式，1表示拼写单词模式
const modeRandom = ref(0)

//选择框的ref
const selectBox1 = ref(null)
const selectBox2 = ref(null)
const selectBox3 = ref(null)
const selectBox4 = ref(null)

// 接收子组件传递的值
const handleSpellingUpdate = (value) => {
  spellingValue.value = value
  console.log('当前拼写:', value)
}

const getModeRandom = () => {
  modeRandom.value = Math.floor(Math.random() * 2)
}

const formatTime = (time) => {
  return time < 10 ? `0${time}` : time.toString();
};

let startTimer;

// 用总毫秒数统一管理时间
let totalMilliseconds = 0;

// 分解时间单位
let minutes = Math.floor(totalMilliseconds / 60000);
let seconds = Math.floor((totalMilliseconds % 60000) / 1000);
let centiseconds = Math.floor((totalMilliseconds % 1000) / 10);

//记忆测试的单词的id索引
const testWordID = ref(0)

//选择释义模式的选项
const translationSelectArray = ref([
  {
    type: '',
    translation: ''
  }
])

const reset = async () => {
  try {
    const confirmed = await ElMessageBox.confirm('是否重置学习？这将恢复所有单词到初始状态', '重置学习', {
      confirmButtonText: '确定',
      cancelButtonText: '取消',
    })

    if (!confirmed) return
    const { data: originalWords } = await axios.get("http://localhost:3000/word")

    const { data: beforeMemeryWords } = await axios.get("http://localhost:3000/beforeMemery")

    // 批量删除现有记忆单词
    await Promise.all(
      beforeMemeryWords.map(word =>
        axios.delete(`http://localhost:3000/beforeMemery/${word.id}`)
      )
    )

    const addedWords = await Promise.all(
      originalWords.map(word =>
        axios.post("http://localhost:3000/beforeMemery", word)
      )
    )
    console.log('添加单词成功:', addedWords);

    counterStore.beforeMemery = originalWords

    isStart.value = false
    isContinue.value = false
    isPause.value = false
    isEnd.value = false
    wrongNum.value = 0;
    respondCount.value = 0;
    isAllDone.value = false

    ElMessage.success('重置成功，所有单词已恢复初始状态')

  } catch (error) {
    console.error('重置失败:', error)
    ElMessage.error('重置失败，请稍后重试')
  }
}

// 随机生成4个单词的释义
const getRandomSelectArray = () => {
  return new Promise((resolve) => {
    const r = Math.floor(Math.random() * counterStore.beforeMemery.length)
    const correctItem = counterStore.beforeMemery[r]

    testWordID.value = correctItem.id
    wordTest_word.value = correctItem.word
    correctionChoosed.value = `${correctItem.wordArray[0].type}${correctItem.wordArray[0].translation}`

    // 初始化选项数组
    translationSelectArray.value = [{
      type: correctItem.wordArray[0].type,
      translation: correctItem.wordArray[0].translation
    }]

    // 准备干扰项词库
    const filteredWords = counterStore.wholeWordList
      .filter(item => item.id !== correctItem.id)
      .sort(() => 0.5 - Math.random())
      .slice(0, 3)

    // 合并选项
    translationSelectArray.value = [
      ...translationSelectArray.value,
      ...filteredWords.map(item => ({
        type: item.wordArray[0].type,
        translation: item.wordArray[0].translation
      }))
    ]

    // 补充空缺项
    while (translationSelectArray.value.length < 4) {
      translationSelectArray.value.push({
        type: '空缺项',
        translation: '选项不足'
      })
    }

    // 洗牌选项
    translationSelectArray.value = translationSelectArray.value
      .sort(() => 0.5 - Math.random())

    resolve()
  })
}

// 随机生成拼写单词模式的单词
const getRandomWordSpelling = () => {
  const rnd = Math.floor(Math.random() * counterStore.beforeMemery.length)
  testWordID.value = counterStore.beforeMemery[rnd].id
  const answer = counterStore.beforeMemery[rnd].word
  spellingAnswer.value = answer
  wordTest_spelling.value = counterStore.beforeMemery[rnd].wordArray[0].translation
  spellingLength.value = counterStore.beforeMemery[rnd].word.length
}

// 生成新题目的方法
const generateNewQuestion = async () => {
  if (isAllDone.value) {
    ElNotification({
      type: 'success',
      title: '记忆完成',
      message: '所有单词已记忆完毕！',
      position: 'bottom-right',
      duration: 3000
    })
    isAllDone.value = true
    end()
    return
  }

  // 等待DOM更新
  await nextTick()

  // 强制重置选项数组
  translationSelectArray.value = []

  getModeRandom()

  if (modeRandom.value === 0) {
    getRandomSelectionBoxColor()
    await getRandomSelectArray()
  } else {
    getRandomWordSpelling()
  }

  // 强制更新选项数组
  translationSelectArray.value = [...translationSelectArray.value]

  // 重置交互状态
  isChoosed.value = false
  spellingValue.value = ''

  // 拼写模式自动聚焦
  if (modeRandom.value === 1) {
    await nextTick()
    if (spellingBoxRef.value?.resetInputs) {
      await spellingBoxRef.value.resetInputs()
    } else {
      await getRandomWordSpelling()
    }
  }
}

const start = () => {
  // 重置统计
  wrongNum.value = 0
  respondCount.value = 0

  // 首次生成题目
  generateNewQuestion()
  isStart.value = true;
  isContinue.value = true
  isEnd.value = false
  startTimer = setInterval(() => {
    totalMilliseconds += 10;

    minutes = Math.floor(totalMilliseconds / 60000);
    seconds = Math.floor((totalMilliseconds % 60000) / 1000);
    centiseconds = Math.floor((totalMilliseconds % 1000) / 10);

    consumingTime_minute.value = formatTime(minutes);
    consumingTime_second.value = formatTime(seconds);
    consumingTime_centisecond.value = formatTime(centiseconds);

    endTime.value = consumingTime_minute.value + ':' + consumingTime_second.value + ':' + consumingTime_centisecond.value;

  }, 10);
};

const pause = () => {
  isPause.value = true
  isContinue.value = false
  clearInterval(startTimer)
}

const Continue = () => {
  isContinue.value = true
  isPause.value = false
  startTimer = setInterval(() => {
    totalMilliseconds += 10;

    // 分解时间单位
    minutes = Math.floor(totalMilliseconds / 60000);
    seconds = Math.floor((totalMilliseconds % 60000) / 1000);
    centiseconds = Math.floor((totalMilliseconds % 1000) / 10);

    consumingTime_minute.value = formatTime(minutes);
    consumingTime_second.value = formatTime(seconds);
    consumingTime_centisecond.value = formatTime(centiseconds);

    endTime.value = consumingTime_minute.value + ':' + consumingTime_second.value + ':' + consumingTime_centisecond.value;

  }, 10);
}
const end = () => {
  if (!isStart.value) {
    ElMessage({
      type: 'error',
      message: '未开始计时',
    })
    return;
  }

  clearInterval(startTimer)
  ElMessageBox.confirm('是否结束学习？', '结束学习', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
  }).then(async () => {
    // 计算并更新上次完成度和准确率
    const correctCount = respondCount.value - wrongNum.value
    lastFinishWords.value = correctCount
    correctPercent.value = respondCount.value > 0
      ? Math.round((correctCount / respondCount.value) * 100)
      : 0

    // 保存到数据库
    try {
      await axios.put("http://localhost:3000/lastRespond", {
        respondWords: lastFinishWords.value,
        accuracy: correctPercent.value
      })
    } catch (error) {
      console.error('更新最后答题记录失败:', error)
    }

    ElMessage({
      type: 'success',
      message: `学习结束，您的最终耗时为:${endTime.value}`,
    })

    // 获取当前时间和最后更新时间
    const currentDate = new Date()
    const str = (counterStore.targetDate).slice(0, 10)
    const lastUpdated = dayjs(str).toDate()

    // 计算时间差（毫秒）1天是86,400,000毫秒
    const timeDiff = currentDate.getTime() - lastUpdated.getTime()
    if (timeDiff > 86400000) {
      targetDay.value += 1
      counterStore.targetDate = currentDate.toLocaleDateString()
      console.log('目标天数+1:', targetDay.value);
    }

    // 重置状态
    isStart.value = false
    isContinue.value = false
    isPause.value = false
    isEnd.value = true
    consumingTime_centisecond.value = '00'
    consumingTime_second.value = '00'
    consumingTime_minute.value = '00'
    minutes = 0
    seconds = 0
    centiseconds = 0
    totalMilliseconds = 0
    endTime.value = 0
    wordTest_word.value = ''
    correctionChoosed.value = ''
    wordTest_spelling.value = ''
    spellingLength.value = 0
    spellingAnswer.value = ''
    translationSelectArray.value = [
      {
        type: '',
        translation: ''
      }
    ]
  }).catch(() => {
    Continue()
    ElMessage({
      type: 'success',
      message: '继续计时',
    })
  })
}

//答案提示
const incapable = () => {
  if (isAllDone.value) {
    ElMessage({
      type: 'info',
      message: '所有单词已完成，没有提示了',
    })
    return;
  }

  ElMessageBox.confirm('是否确定显示答案？', '忘记该词了', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
  }).then(() => {
    if (modeRandom.value === 0) {
      ElNotification({
        type: 'info',
        message: '答案：' + correctionChoosed.value,
        position: 'bottom-right',
        duration: 5000,
      })
    } else {
      ElNotification({
        type: 'info',
        message: '答案：' + spellingAnswer.value,
        position: 'bottom-right',
        duration: 5000,
      })
    }
  })
}

// 校验单词
const verify = async (rnd) => {
  if (isAllDone.value) {
    ElMessage({
      type: 'info',
      message: '所有单词已完成，没有题目了',
    })
    return;
  }
  try {
    isCorrect.value = false
    respondCount.value += 1

    const isAnswerCorrect = rnd === 0
      ? checkSelectionCorrect()
      : checkSpellingCorrect()

    if (!isAnswerCorrect) {
      wrongNum.value += 1
      console.log('错误次数+1:', wrongNum.value);

      showErrorNotification(rnd)
      return
    }

    await handleCorrectAnswer()
  } catch (error) {
    console.error('校验出错:', error)
    ElMessage.error('处理答案时发生错误')
  }
}

// 检查选择是否正确
const checkSelectionCorrect = () => {
  const selectedBox = [selectBox1, selectBox2, selectBox3, selectBox4]
    .find(box => box.value?.$el.classList.contains('selectionChoosed'))

  if (!selectedBox) return false

  const str = selectedBox.value.$slots.type()[0].children +
    selectedBox.value.$slots.translation()[0].children
  return str === correctionChoosed.value
}

// 检查拼写是否正确
const checkSpellingCorrect = () => {
  return spellingValue.value === spellingAnswer.value
}

// 处理正确答案
const handleCorrectAnswer = async () => {
  const index = counterStore.beforeMemery.findIndex(item => item.id === testWordID.value)
  if (index === -1) return

  // 记录删除的单词用于回滚
  const deletedWord = counterStore.beforeMemery[index]

  try {
    // 先更新本地数据
    counterStore.beforeMemery.splice(index, 1)

    // 同步到服务器
    await axios.delete(`http://localhost:3000/beforeMemery/${testWordID.value}`)

    // 更新题目
    await generateNewQuestion()
    if (isAllDone.value) {
      ElNotification({
        type: 'info',
        message: '所有单词已完成，没有题目了',
        position: 'bottom-right',
        duration: 2000,
      })
      return
    }

    ElNotification({
      type: 'success',
      title: '校验成功',
      message: "回答正确！正在加载下一题",
      position: 'bottom-right',
      duration: 2000,
    })
    spellingValue.value = ''

  } catch (error) {
    // 回滚本地数据
    counterStore.beforeMemery.splice(index, 0, deletedWord)
    throw error
  }
}

// 显示错误通知
const showErrorNotification = (modeType) => {
  const messages = {
    0: "回答错误！请重新选择",
    1: "回答错误！请重新输入"
  }

  ElNotification({
    type: 'error',
    title: '校验失败',
    message: messages[modeType],
    position: 'bottom-right',
    duration: 2000,
  })
}

const colorCount = 5;
const selectionSize = 4;

const randomColorIndex = ref([]);
const randomSelectionColorBox = ref(Array.from({ length: colorCount }, () => false));

const getRandomSelectionBoxColor = () => {
  // 创建候选索引数组
  const candidates = Array.from({ length: colorCount }, (_, i) => i);

  // Fisher-Yates 洗牌算法
  for (let i = candidates.length - 1; i > 0; i--) {
    const j = Math.floor(Math.random() * (i + 1));
    [candidates[i], candidates[j]] = [candidates[j], candidates[i]];
  }

  // 获取前N个选择
  const selected = candidates.slice(0, selectionSize);
  console.log('随机选择颜色:', selected);


  // 更新响应式数据
  randomColorIndex.value = selected;

  // 更新选择状态
  randomSelectionColorBox.value = randomSelectionColorBox.value.map(
    (_, idx) => selected.includes(idx)
  );
}

// 自动保存
const autoSave = async () => {
  try {
    await axios.put("http://localhost:3000/dailyTarget", {
      targetWords: counterStore.dailyScheduleProps,
      targetDays: targetDay.value,
      targetDate: dayjs().format('YYYY-MM-DD')
    })
  } catch (e) {
    console.error('自动保存失败:', e)
  }
}

// 使用防抖而不是节流
const debouncedAutoSave = useDebounceFn(autoSave, 3000)

// 监听需要保存的数据变化
watch(() => [
  counterStore.dailyScheduleProps,
  targetDay.value
], debouncedAutoSave, { deep: true })

onMounted(() => {
  window.addEventListener('beforeunload', autoSave)
})

onUnmounted(() => {
  window.removeEventListener('beforeunload', autoSave)
})

onMounted(async () => {
  try {
    const res = await axios.get("http://localhost:3000/dailyTarget")
    console.log('data:', res.data);

    targetDay.value = res.data.targetDays
    counterStore.dailyScheduleProps = res.data.targetWords
    counterStore.targetDate = res.data.targetDate


    const res1 = await axios.get("http://localhost:3000/beforeMemery")
    counterStore.beforeMemery = res1.data
    console.log(res1.data);
    if (res1.data.length === 0) {
      isAllDone.value = true
    }

    const res2 = await axios.get("http://localhost:3000/lastRespond")
    console.log(res2.data);
    lastFinishWords.value = res2.data.respondWords
    correctPercent.value = res2.data.accuracy

  } catch (error) {
    console.error('数据获取失败:', error)
    // 处理错误情况
    ElMessage.error('数据加载失败，请稍后重试')
  }
})

onUnmounted(async () => {
  try {
    const resData = {
      targetWords: counterStore.dailyScheduleProps,
      targetDays: targetDay.value,
      targetDate: dayjs().format('YYYY-MM-DD') // 使用标准日期格式
    }
    const resData2 = {
      respondWords: lastFinishWords.value,
      accuracy: correctPercent.value,
    }
    await axios.put("http://localhost:3000/dailyTarget", resData)
    await axios.put("http://localhost:3000/lastRespond", resData2)
  } catch (e) {
    console.error('保存失败:', e)
  }

})

// 修改日期比对逻辑
watch(() => counterStore.targetDate, (newDate) => {
  const today = dayjs().format('YYYY-MM-DD')
  if (dayjs(newDate).isBefore(today, 'day')) {
    targetDay.value = 0
    counterStore.dailyScheduleProps = 0
  }
}, { immediate: true })

watch(onkeyup, () => {
  verify(modeRandom.value)
})

const scheduleData = computed(() => ({
  finishedWords: counterStore.wholeWordList?.length - counterStore.beforeMemery?.length || 0,
  unFinishedWords: counterStore.beforeMemery?.length || 0
}))

const scheduleDataRight = computed(() => ({
  correctRespond: respondCount.value - wrongNum.value,
  wrongNum: wrongNum.value,
  unFinishedWords: counterStore.beforeMemery?.length || 0
}))
</script>

<template>
  <div class="recordWord">
    <div class="schedule-container">
      <BaseChart :finishedWords="scheduleData.finishedWords" :unfinishedWords="scheduleData.unFinishedWords">
      </BaseChart>
      <button class="reset-button" @click="reset()">重置</button>
      <targetBox>
        <template v-slot:title>每日进度</template>
        <template v-slot:schedule>{{ scheduleDataRight.correctRespond }}/{{ counterStore.dailyScheduleProps
          }}</template>
        <template v-slot:row>已坚持</template>
        <template v-slot:num>{{ targetDay }}</template>
        <template v-slot:unit>天</template>
      </targetBox>
      <targetBox>
        <template v-slot:title>上次完成度</template>
        <template v-slot:schedule>{{ lastFinishWords }}</template>
        <template v-slot:row>准确率</template>
        <template v-slot:num>{{ correctPercent }}</template>
        <template v-slot:unit>%</template>
      </targetBox>
      <button class="add-button" @click="customTarget()">定制目标</button>
    </div>

    <!-- 主要功能区 -->
    <div class="recordingArea">
      <div class="recordingTitle">
        <decorationBox class="descoration"></decorationBox>
        <h3 class="inside-title">随机记忆</h3>
      </div>
      <div class="buttonArea">
        <button class="recording-button" v-if="!isStart" @click="start()">开始</button>
        <button class="recording-button" v-if="isContinue" @click="pause()">暂停</button>
        <button class="recording-button" v-if="isPause" @click="Continue()">继续</button>
        <button class="recording-button end-button" @click="end()">结束</button>
      </div>

      <div class="partingLine"></div>
      <div v-show="isStart">
        <div class="wordAndTime">
          <h3 v-if="modeRandom === 0">单词：{{ wordTest_word }}</h3>
          <h3 v-else>释义：{{ wordTest_spelling }}</h3>
          <h3>耗时：{{ consumingTime_minute }} : {{ consumingTime_second }} : {{ consumingTime_centisecond }}</h3>
        </div>

        <!-- 选择释义模式 -->
        <div v-if="modeRandom === 0">
          <h3 style="position: relative; top: 12vh; left: 3vw; font-size: 1.3rem;">选择释义：</h3>
          <div class="selectExplanation" :class="{ 'question-change': isCorrect }">

            <selectBox ref="selectBox1" :class="{ selectionChoosed: isChoosed == 1 }" @click="isChoosed = 1"
              :bgcColorIndex="randomColorIndex[0]">
              <template v-slot:type>
                {{ translationSelectArray[0]?.type }}
              </template>
              <template v-slot:translation>
                {{ translationSelectArray[0]?.translation }}
              </template>
            </selectBox>

            <selectBox ref="selectBox2" :class="{ selectionChoosed: isChoosed == 2 }" @click="isChoosed = 2"
              :bgcColorIndex="randomColorIndex[1]">
              <template v-slot:type>
                {{ translationSelectArray[1]?.type }}
              </template>
              <template v-slot:translation>
                {{ translationSelectArray[1]?.translation }}
              </template>
            </selectBox>

            <selectBox ref="selectBox3" :class="{ selectionChoosed: isChoosed == 3 }" @click="isChoosed = 3"
              :bgcColorIndex="randomColorIndex[2]">
              <template v-slot:type>
                {{ translationSelectArray[2]?.type }}
              </template>
              <template v-slot:translation>
                {{ translationSelectArray[2]?.translation }}
              </template>
            </selectBox>

            <selectBox ref="selectBox4" :class="{ selectionChoosed: isChoosed == 4 }" @click="isChoosed = 4"
              :bgcColorIndex="randomColorIndex[3]">
              <template v-slot:type>
                {{ translationSelectArray[3]?.type }}
              </template>
              <template v-slot:translation>
                {{ translationSelectArray[3]?.translation }}
              </template>
            </selectBox>
          </div>
        </div>

        <!-- 拼写单词模式 -->
        <div v-else>
          <div class="spellingMode">
            <div>
              <spellingBox :spellingLength="spellingLength" ref="spellingBoxRef" @update:value="handleSpellingUpdate"
                @keydown.enter="verify(modeRandom)">
              </spellingBox>
            </div>

          </div>

        </div>
        <rightChart class="chart-right" :correctRespond="scheduleDataRight.correctRespond"
          :unfinishedWords="scheduleDataRight.unFinishedWords" :wrongNum="scheduleDataRight.wrongNum"></rightChart>

        <button class="submit-button" @click="verify(modeRandom)" @verify="verify(modeRandom)">校验</button>
        <button class="slip-button" @click="incapable()">不会</button>
      </div>
    </div>
  </div>
</template>
<style scoped lang="scss">
.recordWord {
  position: relative;
  height: 90vh;
  width: 100%;
}

.schedule-container {
  position: relative;
  display: flex;
  align-items: center;
  height: 30%;
  width: 100%;
  background-color: #fff;
}

.reset-button {
  position: relative;
  top: 7vh;
  height: 40px;
  width: 40px;
  background-color: #FFD978;
  font-size: 0.8rem;
  font-weight: 600;
  color: #545353;

  border: {
    style: none;
    radius: 50%;
  }
}

.recordingArea {
  position: relative;
  width: 100%;
  top: 1.5vh;
  height: 68%;
  border-radius: 10px;
  box-shadow: 0px 2px 7px -1px #C4FFAF;
  display: flex;
  flex-direction: column;
  // background-color: #c93b3b;
}

.inside-title {
  position: relative;
  user-select: none;
  width: 5vw;
  left: 1.5vw;
  font-size: 1.5rem;
}

.recordingTitle {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  left: 1vw;
  top: 1.5vh;
}

.descoration {
  position: relative;
}

.add-button {
  position: relative;
  width: 7vw;
  height: 3vh;
  left: -25.5%;
  top: 6.5vh;
  background-color: #FFD978;
  font-size: 1rem;
  font-weight: 600;
  color: #545353;
  margin-right: 2vw;

  border: {
    style: none;
    radius: 8px;
  }
}

.buttonArea {
  position: relative;
  display: flex;
  flex-direction: row;
  width: 90%;
  height: 4vh;
  left: 1vw;
  top: 4vh;
  // background-color: #762f2f;
}

.recording-button {
  position: relative;
  width: 7vw;
  height: 4vh;
  left: 2vw;
  top: 0.5vh;
  background-color: #B1EAFF;
  font-size: 1.2rem;
  font-weight: 600;
  color: #ffffff;
  margin-right: 2vw;

  border: {
    style: none;
    radius: 12px;
  }
}

.end-button {
  background-color: #FFC7D4;
}

.partingLine {
  position: relative;
  height: 0.18vh;
  width: 97vw;
  left: 1vw;
  background-color: #FFD978;
  top: 7vh;
}

.wordAndTime {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 93%;
  height: 4vh;
  left: 3vw;
  top: 10vh;
  // background-color: #762f2f;
}

.selectExplanation {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  width: 80%;
  height: auto;
  left: 3vw;
  top: 15vh;
  // background-color: #762f2f;
}

.submit-button {
  position: absolute;
  width: 10%;
  height: 3.5vh;
  left: 35%;
  top: 54vh;
  background-color: #b3ffb7;
  font-size: 1.2rem;
  font-weight: 600;
  color: #ffffff;
  margin-right: 2vw;

  border: {
    style: none;
    radius: 8px;
  }
}

.slip-button {
  position: absolute;
  width: 10%;
  height: 3.5vh;
  left: 48%;
  top: 54vh;
  background-color: #ffb1e5;
  font-size: 1.2rem;
  font-weight: 600;
  color: #ffffff;
  margin-right: 2vw;

  border: {
    style: none;
    radius: 8px;
  }
}

.chart-right {
  position: absolute;
  left: 86%;
  top: 28vh;
}

.spellingMode {
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  width: 88%;
  height: auto;
  // left: 3vw;
  top: 12vh;
  // background-color: #762f2f;
}

.selectionChoosed {
  font-weight: 600;
  transform: scale(1.1);
  border-style: dashed;
  border-color: #ffffff;
  border-width: 2px;
  // filter: blur(2px);
}

/* 添加过渡动画 */
.select-box {
  transition: all 0.3s ease;
}

.question-change {
  animation: fadeIn 0.5s;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
</style>
